#!/usr/bin/env python3.10
# -*- encoding: utf-8 -*-
'''
@File    :   posts.py
@Time    :   2023/05/04 17:15:51
@Author  :   windstarry 
@Version :   1.0
'''
# here put the import lib
from tortoise import fields
from .base import BaseModel


class PostModel(BaseModel):
    """
    文章表
    title必须唯一,index=True设置索引方便检索
    """ 
    title = fields.CharField(max_length=255, default='',description="文章标题",unique=True,index=True)
    description = fields.TextField(default='', null=True,description="文章简介")
    author = fields.CharField(max_length=30, default='windstarry',description="文章作者")
    content = fields.TextField(default='', null=True, blank=True,description="文章正文")   
    can_comment = fields.BooleanField(default=True,description="文章是否开启评论")
    is_published = fields.BooleanField(default=True, description="文章是否公开")

    class Meta:
        table = "sys_posts"
        table_description = "文章表"
        # 索引
        unique_together = ("title",)